package edu.nxmu.supersiver.service.impl;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import edu.nxmu.supersiver.bean.Users;
import edu.nxmu.supersiver.dao.UsersDao;
import edu.nxmu.supersiver.service.UsersService;
@Service("usersService")
public class UsersServiceImpl implements UsersService {

	@Autowired
	private UsersDao usersDao;

	@Override
	public Users checkLogin(String username, String password) {
		return usersDao.checkLogin(username, password);
	}

	@Override
	public void update(Users user) {
		usersDao.update(user);
	}

	@Override
	public void addUser(Users user) {
		usersDao.save(user);
	}

	@Override
	public Users getById(int id) {
		return usersDao.get(id);
	}

	@Override
	public Users getByUsername(String username) {
		return usersDao.getByUsername(username);
	}

	@Override
	public List<Users> getAllUsers() {
		return usersDao.findAll();
	}

	@Override
	public void delete(int id) {
		usersDao.deleteById(id);
	}

	@Override
	public void enable(int id) {
		usersDao.enable(id);
	}

	@Override
	public void disable(int id) {
		usersDao.disable(id);
	}

	@Override
	public List<Users> getUsersForPage(int pageNo, int pageSize) {
		return usersDao.getAllPage(pageNo, pageSize);
	}

	@Override
	public int getRows() {
		return usersDao.getAllRows();
	}

	@Override
	public List<Users> getUsersFroPage(String subUsername, int pageNo, int pageSize) {
		return usersDao.getUsersForPage(subUsername, pageNo, pageSize);
	}

	@Override
	public int getRowsForPage(String subUsername) {
		return usersDao.getRowsForPage(subUsername);
	}

}
